package org.example.DesignPatterns.State;

/**
 * @description:
 * @author: farprt
 * @create: 2022-09-23 18:23
 **/
public class TrafficLight {

    State state=new Red();//初始状态为红灯

    public void setState(State state) {
        this.state = state;
    }

    public void switchToGreen(){
        state.switchToGreen(this);
    }

    public void switchToYellow(){
        state.switchToYellow(this);
    }

    public void switchToRed(){
        state.switchToRed(this);
    }
}